<template>
  <div class="body clear">
    <div class="set">
      <span>我的</span>
      <van-icon name="setting-o" class="img" @click="toSet" />
    </div>
    <div class="body-in">
      <div class="user">
        <div class="left">
          <img :src="userMsg?.userPhoto ? userMsg.userPhoto : 'http://116.62.149.160:4000/girl.jpg'" alt="" />
        </div>
        <div class="middle">
          <p class="top">{{ userMsg ? userMsg.nickname : null }}</p>
          <span class="middle">13个勋章</span>
          <div class="bottom">
            <span>动态 43</span>
            <span>关注 230</span>
            <span>粉丝 12</span>
          </div>
        </div>
        <div class="right">
          <p>领取一万积分</p>
        </div>
      </div>
      <div class="create-center">
        <p class="create-header">创作者中心</p>
        <div class="create-body">
          <div class="body-item" v-for="item in 5" :key="item">
            <img src="@/assets/advertisement.png" alt="" />
            <p>创作首页</p>
          </div>
        </div>
        <div class="create-foot">
          <span class="foot-left">发布你的第一篇内容</span>
          <div class="foot-right"><span>发布</span></div>
        </div>
      </div>
      <div class="notice">
        <div class="user-notice">
          <div class="notice-item" v-for="item in 5" :key="item">
            <img src="@/assets/advertisement.png" alt="" />
            <p>消息通知</p>
          </div>
        </div>
        <div class="notice-centent">
          <span class="left"></span>
          <span class="rigth"></span>
        </div>
        <div class="notice-swiper">
          <van-swipe :autoplay="3000" lazy-render :show-indicators="false">
            <van-swipe-item v-for="image in images" :key="image">
              <img :src="image" />
            </van-swipe-item>
          </van-swipe>
        </div>
      </div>
      <div class="integral">
        <div class="ig-user">
          <span>我的积分</span>
          <span>0 ></span>
        </div>
        <div class="ig-content">
          <div class="ig-item" v-for="item in 4" :key="item">
            <img src="@/assets/advertisement.png" alt="" class="_img" />
            <p>积分商城</p>
            <p class="min">赚积分换豪礼</p>
          </div>
        </div>
      </div>
      <div class="my-car">
        <div class="my-car-header">
          <span class="item" style="font-size: 16px">我的爱车</span>
          <span class="item">南昌</span>
          <span class="item">不限行</span>
        </div>
        <div class="my-car-content">
          <div class="content-item" v-for="item in 5" :key="item">
            <img src="@/assets/advertisement.png" alt="" />
            <p>添加爱车</p>
          </div>
        </div>
        <div class="my-car-foot">
          <div class="foot-item" v-for="item in 2" :key="item">
            <div class="item-left">
              <p>汽车装饰用品</p>
              <p style="font-size: 12px">专车专用</p>
            </div>
            <div class="item-right">
              <img src="@/assets/advertisement.png" alt="" />
            </div>
          </div>
        </div>
      </div>
      <div class="common">
        <p class="common-head">常用功能</p>
        <div class="common-body">
          <div class="common-content" v-for="item in 5" :key="item + '1'">
            <img src="@/assets/advertisement.png" alt="" />
            <p>浏览记录</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { reactive, toRefs } from "vue";
import advertisement from "@/assets/advertisement.png";
import { useRouter } from "vue-router";
import { getUserMsg } from "@/tool/getUserMsg";
export default {
  name: "usersCenter",
  setup() {
    const images = [advertisement, advertisement, advertisement];
    const router = useRouter();
    const toSet = () => {
      return router.push({ path: "/user/userSet" });
    };
    const state = reactive({
      userMsg:
        getUserMsg() ||
        null,
    });
    return { images, ...toRefs(state), advertisement, toSet };
  },
};
</script>

<style lang='less' scoped>
.body {
  width: 100%;
  height: 100%;
  .set {
    background: #fff;
    position: fixed;
    top: 0px;
    box-sizing: border-box;
    padding-top: 5px;
    line-height: 20px;
    text-align: center;
    width: 100%;
    .img {
      padding: 10px auto;
      float: right;
      width: 5%;
      height: 20px;
      padding-right: 10px;
    }
  }
  .body-in {
    padding-top: 40px;
    background: #fff;
    box-sizing: border-box;
    margin-bottom: 50px;
    .user {
      padding-left: 10px;
      box-sizing: border-box;
      width: 100%;
      display: flex;
      .left {
        flex: 0 0 70px;
        img {
          border-radius: 50%;
          width: 100%;
          height: 100%;
        }
      }
      .middle {
        text-align: left;
        margin-left: 10px;
        flex: 1;
        width: 100%;
        .top {
          font-size: 18px;
        }
        .middle {
          line-height: 18px;
          padding: 0 10px;
          // display: inline-block;
          font-size: 14px;
          border-radius: 10px;
          background: #ccc;
          overflow: hidden;
        }
        .bottom {
          display: flex;
          span {
            flex: 1;
            font-size: 14px;
          }
        }
      }
      .right {
        flex: 0 0 80px;
        text-align: right;
        line-height: 30px;
        p {
          border-top-left-radius: 20px;
          border-bottom-left-radius: 20px;
          font-size: 12px;
          background: greenyellow;
        }
      }
    }
    .create-center {
      border-bottom: 5px solid #ddd;
      padding: 10px;
      box-sizing: border-box;
      background: #fff;
      width: 100%;
      .create-header {
        text-align: left;
        font-size: 18px;
        width: 100%;
      }
      .create-body {
        display: flex;
        width: 100%;
        .body-item {
          margin: 20px auto 0 auto;
          box-sizing: border-box;
          flex: 1;
          width: 80%;
          img {
            width: 100%;
            height: auto;
            padding-bottom: 15px;
          }
          p {
            font-size: 14px;
            text-align: center;
            line-height: 20px;
            padding-bottom: 10px;
          }
        }
      }
      .create-foot {
        padding: 0 15px;
        box-sizing: border-box;
        border-radius: 5px;
        background: #eee;
        line-height: 30px;
        height: 30px;
        width: 100%;
        .foot-left {
          height: 100%;
          float: left;
          font-size: 12px;
        }
        .foot-right {
          float: right;
          font-size: 12px;
          span {
            display: inline-block;
            line-height: 20px;
            background: yellowgreen;
            padding: 0 10px;
          }
        }
      }
    }
    .notice {
      background: #fff;
      padding: 0 10px;
      box-sizing: border-box;
      width: 100%;
      padding: 10px;
      border-bottom: 5px solid #ddd;
      .user-notice {
        margin: 10px auto;
        display: flex;
        width: 100%;
        .notice-item {
          flex: 1;
          width: 20%;
          p {
            font-size: 14px;
            text-align: center;
          }
          img {
            width: 100%;
          }
        }
      }
      .notice-swiper {
        height: 100px;
        .van-swipe {
          height: 100%;
        }
        img {
          width: 100%;
          height: 100px;
        }
      }
    }
    .integral {
      padding: 5px 10px;
      box-sizing: border-box;
      width: 100%;
      border-bottom: 5px solid #ddd;
      .ig-user {
        display: flex;
        justify-content: space-between;
        width: 100%;
        line-height: 18px;
        margin: 10px auto;
      }
      .ig-content {
        display: flex;
        width: 100%;
        .ig-item {
          flex: 1;
          width: 25%;
          img {
            width: 100%;
          }
          p {
            font-size: 14px;
            text-align: center;
          }
          .min {
            font-size: 8px;
          }
        }
      }
    }
    .my-car {
      padding: 10px 10px;
      box-sizing: border-box;
      width: 100%;
      border-bottom: 5px solid #ddd;
      .my-car-header {
        width: 100%;
        text-align: left;
        .item {
          width: 15%;
          font-size: 14px;
          padding: 0 5px;
        }
      }
      .my-car-content {
        display: flex;
        margin: 10px auto;
        width: 100%;
        .content-item {
          flex: 1;
          width: 25%;
        }
        img {
          width: 100%;
        }
        p {
          font-size: 14px;
          text-align: center;
        }
      }
      .my-car-foot {
        display: flex;
        width: 100%;
        .foot-item {
          background: #def;
          flex: 1;
          display: flex;
          align-items: center;
          width: 50%;
          text-align: left;
          margin: 0 5px;
          padding: 0 5px;
          .item-left {
            flex: 1;
            font-size: 16px;
          }
          .item-right {
            flex: 0 0 40px;
            width: 100%;
            img {
              width: 40px;
              height: 24px;
              border-radius: 50%;
            }
          }
        }
      }
    }
    .common {
      padding: 0 10px;
      box-sizing: border-box;
      width: 100%;
      padding-bottom: 50px;
      .common-head {
        font-size: 18px;
        text-align: left;
        padding: 5px;
      }
      .common-body {
        display: flex;
        flex-wrap: wrap;
        // justify-content: center;
        align-items: center;
        .common-content {
          width: 25%;
          p {
            font-size: 14px;
            text-align: center;
          }
          img {
            width: 100%;
          }
        }
      }
    }
  }
  .clear {
    clear: both;
  }
}
p {
  margin: 0;
}
</style>